'revoke C1 account by given ID in text
'author: chaoyuew@cn.ibm.com
'updated on 29/07/2016 based on "Add Groups-Todo-Sales Based On Model ID.vbs"


ExecuteGlobal CreateObject("Scripting.FileSystemObject").OpenTextFile("C1 Invoked Function.vbs",1).ReadAll'调用函数库
num =inputbox("Please select C1Env: " & vbCrLf & vbCrLf &"1.PROD    6.FC1  11.SIT2C  16.TRNM" & vbCrLf &"2.BET1    7.FC2  12.ST2    17.UAT1" & vbCrLf & "3.CAR     8.FC4  13.ST3    18.UATA" & vbCrLf & "4.CCBPRE1 9.M2C  14.TRN1   19.ST5U " & vbCrLf & "5.CCBPS1 10.SIT1 15.TRN2   20.FC4"& vbCrLf,"Enter required details","1")
If IsEmpty(num) Then Wscript.Quit
winstr = Split(GetC1Env(num), "cis.jsp", -1, 1)(0) & "uiPage"
CkUserIDTxt : FindC1EnvInIE(GetC1Env(num)) : LogonEnv : SwitchMenu
'----------------------------------------------------------staring loop the  user list'
for n = 0  to UBound(UserIDList)
	validUser(UCase(Trim(UserIDList(n))))
	if isErrorIDFound = "false"  then 
		'<---------------------Locate the  Group Part'
		Do While ie.Busy Or ie.ReadyState <> 4: WScript.Sleep 500: Loop
		Set TabPageContent = ie.document.frames(0).document.getelementbyid("tabPage").contentWindow
		while TabPageContent Is Nothing
			WScript.Sleep 200 : Set TabPageContent = ie.document.frames(0).document.getelementbyid("tabPage").contentWindow
		wend
		Set userGroupGridContent = TabPageContent.document.getelementbyid("userGroupGrid").contentWindow
		Set Groups= userGroupGridContent.document.getelementsbytagname("input")
		dim datechanged : datechanged="false"
		for each item in Groups 'change the expire date if it matches the pattern'
			if item.classname = "data dc-DATE-NONE-10-0 forms" and Len(item.value ) <> 0 then 
				foundDateStr = Split(item.value,"-",-1,1)(1)&"/"&Split(item.value,"-",-1,1)(0)&"/"&Split(item.value,"-",-1,1)(2)
				foundDate = CDate(foundDateStr)
				if foundDate > now then
					item.value=CurrentDate : item.FireEvent("onblur") : datechanged="true"
				end if
			end if
		Next
		if datechanged ="true" then ie.document.frames(0).document.getelementbyid("IM_SAVE").click
		WScript.Sleep 3000
	end if
Next
msgbox "Script finished successfully!"


